package com.touchealth.test.radom;

import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author zhangyanqiang
 * @date 2020/12/31
 **/
public class Radom {

    public static void main(String[] args) {
        ExcelWriter writer =  ExcelUtil.getWriter("/Users/zhangyanqiang/Documents/workspace/self/demo/src/main/java/com/touchealth/test/radom/writeTest.xlsx");

        List<PhoneDto> array = new Vector<>(400);

        AtomicInteger num = new AtomicInteger(506801);
        for (int i=0;i< 400;i++){
            PhoneDto phone = new PhoneDto();
            phone.setId(num.addAndGet(1)+"");
            phone.setPhoneNo(RandomUtil.randomLong(30000000000L,40000000000L)+"");
            phone.setCode(RandomUtil.randomString(10));
            String date = RandomUtil.randomDate(null, DateField.DAY_OF_YEAR,-40,-10).toString(DatePattern.NORM_DATE_FORMAT);
            String hour = RandomUtil.randomInt(24) +"";
            String mini = RandomUtil.randomInt(60)+"";
            String second = RandomUtil.randomInt(60)+"";
            if (hour.length()==1){
                hour = "0"+hour;
            }
            if (mini.length()==1){
                mini = "0"+mini;
            }
            if (second.length()==1){
                second = "0"+second;
            }
            date = date +" "+hour+":"+mini+":"+second;
            phone.setCreatedDate(date);
            array.add(phone);
        }
        writer.write(array);
        writer.close();

    }
}
